package responsibilityChain;

public abstract class AbstractLogger {
    public static int INFO = 1;
    public static int DEBUG = 2;
    public static int ERROR = 3;
    protected int level;
    //责任链的下一个元素
    private AbstractLogger nextLogger;

    public void setNext(AbstractLogger next) {
        this.nextLogger = next;
    }

    public void loggerMesage(int level, String message) {
        if (this.level ==  level) {
            write(message);
        }
        if (this.nextLogger != null) {
            nextLogger.loggerMesage(level,message);
        }
    }

    abstract protected void write(String msg);

}
